/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package resource;

import java.util.List;
import javax.ws.rs.Path;
import org.springframework.beans.factory.annotation.Autowired;
import service.ProductService;
import bean.Product;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

/**
 *
 * @author root
 */
@Path("product")
public class ProductResource {
    
    @Autowired
    private ProductService productService;
    
    /**
     * 得到全部产品展示数据
     * @return 
     */
    @Path("allList")
    @GET
    @Produces({MediaType.APPLICATION_JSON,"application/json;charset=UTF-8","application/x-javascript;charset=UTF-8"})
    public List<Product> getListAllProduct(){
        return productService.getListAllProduct();
    }
    
    /**
     * 分页信息
     * @param protype
     * @param pagesize
     * @param page
     * @return 
     */
    @Path("paging")
    @GET
    @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_XML})
    public List<Product> getListPagingProductByProTypePage(
                @QueryParam("protype") final int protype,
                @QueryParam("pagesize") final int pagesize,
                @QueryParam("page") final int page){
        return productService.getListPagingProductByProTypePage(protype, pagesize, page);
    }
    
    @Path("refresh")
    @GET
    @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Product> getListProductByProTypeRefresh(
            @QueryParam("protype") final int protype,
            @QueryParam("begin") final int begin,
            @QueryParam("readsize")final int readsize){
        return productService.getListProductByProTypeRefresh(protype, begin, readsize);
    }
    
    
}
